from sentence_transformers import SentenceTransformer
import numpy as np
from resume.models import ResumeTemplate

model = SentenceTransformer('paraphrase-multilingual-MiniLM-L12-v2')

def update_template_vectors():
    for template in ResumeTemplate.objects.all():
        text = f"{template.name} {template.desc} {template.tags}"
        vector = model.encode(text)
        # 假设你在模型中加了vector字段（BinaryField或TextField存np数组的tobytes/base64）
        template.vector = vector.tobytes()
        template.save()